<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>
MessageBodyWriter (jersey-bundle 1.9 API)
</TITLE>


<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">

<SCRIPT type="text/javascript">
function windowTitle()
{
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="MessageBodyWriter (jersey-bundle 1.9 API)";
    }
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>

</HEAD>

<BODY BGCOLOR="white" onload="windowTitle();">
<HR>


<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/MessageBodyWriter.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../javax/ws/rs/ext/MessageBodyReader.html" title="interface in javax.ws.rs.ext"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../javax/ws/rs/ext/Provider.html" title="annotation in javax.ws.rs.ext"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../index.html?javax/ws/rs/ext/MessageBodyWriter.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="MessageBodyWriter.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->

<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
javax.ws.rs.ext</FONT>
<BR>
Interface MessageBodyWriter&lt;T&gt;</H2>
<DL>
<DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../../../com/sun/jersey/core/provider/jaxb/AbstractJAXBElementProvider.html" title="class in com.sun.jersey.core.provider.jaxb">AbstractJAXBElementProvider</A>, <A HREF="../../../../com/sun/jersey/core/provider/jaxb/AbstractJAXBProvider.html" title="class in com.sun.jersey.core.provider.jaxb">AbstractJAXBProvider</A>, <A HREF="../../../../com/sun/jersey/core/provider/jaxb/AbstractListElementProvider.html" title="class in com.sun.jersey.core.provider.jaxb">AbstractListElementProvider</A>, <A HREF="../../../../com/sun/jersey/core/provider/AbstractMessageReaderWriterProvider.html" title="class in com.sun.jersey.core.provider">AbstractMessageReaderWriterProvider</A>, <A HREF="../../../../com/sun/jersey/core/provider/jaxb/AbstractRootElementProvider.html" title="class in com.sun.jersey.core.provider.jaxb">AbstractRootElementProvider</A></DD>
</DL>
<HR>
<DL>
<DT><PRE>public interface <B>MessageBodyWriter&lt;T&gt;</B></DL>
</PRE>

<P>
Contract for a provider that supports the conversion of a Java type to a 
 stream. To add a <code>MessageBodyWriter</code> implementation, annotate the
 implementation class with <code>@Provider</code>.

 A <code>MessageBodyWriter</code> implementation may be annotated
 with <A HREF="../../../../javax/ws/rs/Produces.html" title="annotation in javax.ws.rs"><CODE>Produces</CODE></A> to restrict the media types for which it will
 be considered suitable.
<P>

<P>
<DL>
<DT><B>See Also:</B><DD><A HREF="../../../../javax/ws/rs/ext/Provider.html" title="annotation in javax.ws.rs.ext"><CODE>Provider</CODE></A>, 
<A HREF="../../../../javax/ws/rs/Produces.html" title="annotation in javax.ws.rs"><CODE>Produces</CODE></A></DL>
<HR>

<P>

<!-- ========== METHOD SUMMARY =========== -->

<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;long</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../javax/ws/rs/ext/MessageBodyWriter.html#getSize(T, java.lang.Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)">getSize</A></B>(<A HREF="../../../../javax/ws/rs/ext/MessageBodyWriter.html" title="type parameter in MessageBodyWriter">T</A>&nbsp;t,
        java.lang.Class&lt;?&gt;&nbsp;type,
        java.lang.reflect.Type&nbsp;genericType,
        java.lang.annotation.Annotation[]&nbsp;annotations,
        <A HREF="../../../../javax/ws/rs/core/MediaType.html" title="class in javax.ws.rs.core">MediaType</A>&nbsp;mediaType)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called before <code>writeTo</code> to ascertain the length in bytes of 
 the serialized form of <code>t</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../javax/ws/rs/ext/MessageBodyWriter.html#isWriteable(java.lang.Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)">isWriteable</A></B>(java.lang.Class&lt;?&gt;&nbsp;type,
            java.lang.reflect.Type&nbsp;genericType,
            java.lang.annotation.Annotation[]&nbsp;annotations,
            <A HREF="../../../../javax/ws/rs/core/MediaType.html" title="class in javax.ws.rs.core">MediaType</A>&nbsp;mediaType)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ascertain if the MessageBodyWriter supports a particular type.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../javax/ws/rs/ext/MessageBodyWriter.html#writeTo(T, java.lang.Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.OutputStream)">writeTo</A></B>(<A HREF="../../../../javax/ws/rs/ext/MessageBodyWriter.html" title="type parameter in MessageBodyWriter">T</A>&nbsp;t,
        java.lang.Class&lt;?&gt;&nbsp;type,
        java.lang.reflect.Type&nbsp;genericType,
        java.lang.annotation.Annotation[]&nbsp;annotations,
        <A HREF="../../../../javax/ws/rs/core/MediaType.html" title="class in javax.ws.rs.core">MediaType</A>&nbsp;mediaType,
        <A HREF="../../../../javax/ws/rs/core/MultivaluedMap.html" title="interface in javax.ws.rs.core">MultivaluedMap</A>&lt;java.lang.String,java.lang.Object&gt;&nbsp;httpHeaders,
        java.io.OutputStream&nbsp;entityStream)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Write a type to an HTTP response.</TD>
</TR>
</TABLE>
&nbsp;
<P>

<!-- ============ METHOD DETAIL ========== -->

<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>

<A NAME="isWriteable(java.lang.Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)"><!-- --></A><H3>
isWriteable</H3>
<PRE>
boolean <B>isWriteable</B>(java.lang.Class&lt;?&gt;&nbsp;type,
                    java.lang.reflect.Type&nbsp;genericType,
                    java.lang.annotation.Annotation[]&nbsp;annotations,
                    <A HREF="../../../../javax/ws/rs/core/MediaType.html" title="class in javax.ws.rs.core">MediaType</A>&nbsp;mediaType)</PRE>
<DL>
<DD>Ascertain if the MessageBodyWriter supports a particular type.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>type</CODE> - the class of object that is to be written.<DD><CODE>genericType</CODE> - the type of object to be written, obtained either
 by reflection of a resource method return type or via inspection
 of the returned instance. <A HREF="../../../../javax/ws/rs/core/GenericEntity.html" title="class in javax.ws.rs.core"><CODE>GenericEntity</CODE></A>
 provides a way to specify this information at runtime.<DD><CODE>annotations</CODE> - an array of the annotations on the resource
 method that returns the object.<DD><CODE>mediaType</CODE> - the media type of the HTTP entity.
<DT><B>Returns:</B><DD>true if the type is supported, otherwise false.</DL>
</DD>
</DL>
<HR>

<A NAME="getSize(java.lang.Object,java.lang.Class,java.lang.reflect.Type,java.lang.annotation.Annotation[],javax.ws.rs.core.MediaType)"><!-- --></A><A NAME="getSize(T, java.lang.Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)"><!-- --></A><H3>
getSize</H3>
<PRE>
long <B>getSize</B>(<A HREF="../../../../javax/ws/rs/ext/MessageBodyWriter.html" title="type parameter in MessageBodyWriter">T</A>&nbsp;t,
             java.lang.Class&lt;?&gt;&nbsp;type,
             java.lang.reflect.Type&nbsp;genericType,
             java.lang.annotation.Annotation[]&nbsp;annotations,
             <A HREF="../../../../javax/ws/rs/core/MediaType.html" title="class in javax.ws.rs.core">MediaType</A>&nbsp;mediaType)</PRE>
<DL>
<DD>Called before <code>writeTo</code> to ascertain the length in bytes of 
 the serialized form of <code>t</code>. A non-negative return value is 
 used in a HTTP <code>Content-Length</code> header.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>t</CODE> - the instance to write<DD><CODE>type</CODE> - the class of object that is to be written.<DD><CODE>genericType</CODE> - the type of object to be written, obtained either
 by reflection of a resource method return type or by inspection
 of the returned instance. <A HREF="../../../../javax/ws/rs/core/GenericEntity.html" title="class in javax.ws.rs.core"><CODE>GenericEntity</CODE></A>
 provides a way to specify this information at runtime.<DD><CODE>annotations</CODE> - an array of the annotations on the resource
 method that returns the object.<DD><CODE>mediaType</CODE> - the media type of the HTTP entity.
<DT><B>Returns:</B><DD>length in bytes or -1 if the length cannot be determined in
 advance</DL>
</DD>
</DL>
<HR>

<A NAME="writeTo(java.lang.Object,java.lang.Class,java.lang.reflect.Type,java.lang.annotation.Annotation[],javax.ws.rs.core.MediaType,javax.ws.rs.core.MultivaluedMap,java.io.OutputStream)"><!-- --></A><A NAME="writeTo(T, java.lang.Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.OutputStream)"><!-- --></A><H3>
writeTo</H3>
<PRE>
void <B>writeTo</B>(<A HREF="../../../../javax/ws/rs/ext/MessageBodyWriter.html" title="type parameter in MessageBodyWriter">T</A>&nbsp;t,
             java.lang.Class&lt;?&gt;&nbsp;type,
             java.lang.reflect.Type&nbsp;genericType,
             java.lang.annotation.Annotation[]&nbsp;annotations,
             <A HREF="../../../../javax/ws/rs/core/MediaType.html" title="class in javax.ws.rs.core">MediaType</A>&nbsp;mediaType,
             <A HREF="../../../../javax/ws/rs/core/MultivaluedMap.html" title="interface in javax.ws.rs.core">MultivaluedMap</A>&lt;java.lang.String,java.lang.Object&gt;&nbsp;httpHeaders,
             java.io.OutputStream&nbsp;entityStream)
             throws java.io.IOException,
                    <A HREF="../../../../javax/ws/rs/WebApplicationException.html" title="class in javax.ws.rs">WebApplicationException</A></PRE>
<DL>
<DD>Write a type to an HTTP response. The response header map is mutable
 but any changes must be made before writing to the output stream since
 the headers will be flushed prior to writing the response body.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>t</CODE> - the instance to write.<DD><CODE>type</CODE> - the class of object that is to be written.<DD><CODE>genericType</CODE> - the type of object to be written, obtained either
 by reflection of a resource method return type or by inspection
 of the returned instance. <A HREF="../../../../javax/ws/rs/core/GenericEntity.html" title="class in javax.ws.rs.core"><CODE>GenericEntity</CODE></A>
 provides a way to specify this information at runtime.<DD><CODE>annotations</CODE> - an array of the annotations on the resource
 method that returns the object.<DD><CODE>mediaType</CODE> - the media type of the HTTP entity.<DD><CODE>httpHeaders</CODE> - a mutable map of the HTTP response headers.<DD><CODE>entityStream</CODE> - the <CODE>OutputStream</CODE> for the HTTP entity. The 
 implementation should not close the output stream.
<DT><B>Throws:</B>
<DD><CODE>java.io.IOException</CODE> - if an IO error arises
<DD><CODE><A HREF="../../../../javax/ws/rs/WebApplicationException.html" title="class in javax.ws.rs">WebApplicationException</A></CODE> - if a specific 
 HTTP error response needs to be produced. Only effective if thrown prior
 to the response being committed.</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>


<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/MessageBodyWriter.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../javax/ws/rs/ext/MessageBodyReader.html" title="interface in javax.ws.rs.ext"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../javax/ws/rs/ext/Provider.html" title="annotation in javax.ws.rs.ext"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../index.html?javax/ws/rs/ext/MessageBodyWriter.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="MessageBodyWriter.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->

<HR>
Copyright &#169; 2011 <a href="http://www.oracle.com/">Oracle Corporation</a>. All Rights Reserved.
</BODY>
</HTML>
